package cn.edu.stu.interception;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Karl
 * @Date 2022/12/19 - 23:22
 */
public class AttachmentInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(request.getServletPath().endsWith(".mp3"))
            response.setHeader("Content-Disposition","attachment");
        return true;
    }
}
